package com.epi.basic.model;

import lombok.Getter;
import lombok.Setter;

/**
 * @author dxy
 * @version 1.0
 */
public class ResponseVO<T> {
    private StatusDetail detail;
    @Getter @Setter
    private T data;

    private ResponseVO(StatusDetail detail, T data) {
        this.detail = detail;
        this.data = data;
    }


    public static <T> ResponseVO<T> success() {
        return from(SuccessCode.OK, null);
    }

    public static <T> ResponseVO<T> success(T data) {
        return from(SuccessCode.OK, data);
    }

    public static <T> ResponseVO<T> from(StatusDetail detail) {
        return new ResponseVO<>(detail, null);
    }

    public static <T> ResponseVO<T> from(StatusDetail detail, T data) {
        return new ResponseVO<>(detail, data);
    }

    public Integer getCode() {
        return detail.getCode();
    }

    public String getMsg() {
        return detail.getMsg();
    }
}
